/**
 * 
 */

package pos;

import java.sql.Connection;
import java.sql.SQLException;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import pos.auth.Authentication;
import pos.config.LoadConfig;
import pos.interfaces.Database;
import pos.interfaces.Messages;
import pos.storage.StorageFactory;
import pos.ui.screen.LogIn;

/**
 * This is the main class which invokes the GUI and boundary objects
 * @author srikanth ramu
 */

public class Pos implements Messages{

    public static Connection custConn = null;
    public static Connection clerkConn = null;
    public static Connection adminConn = null;
    public static Authentication auth = null ;
    public static LoadConfig conf = null;
    
    public static void main(String[] args) throws UnsupportedLookAndFeelException {
        conf = new LoadConfig("config\\config.properties");
        auth = new Authentication();
        try{
            //com.jtattoo.plaf.acryl.AcrylLookAndFeel
            //com.jtattoo.plaf.aluminium.AluminiumLookAndFeel
            //Invoking the third party theme manager
            UIManager.setLookAndFeel("com.jtattoo.plaf.aluminium.AluminiumLookAndFeel");
//            System.out.println("Path = " + System.getProperty("user.dir"));
            //Getting a DB Connection
            Database mysql = (Database) StorageFactory.getStorage(StorageFactory.DBTYPE, Database.MYSQL);
            custConn = mysql.getConnection(Database.CUSTOMER);
            clerkConn = mysql.getConnection(Database.CLERK);
            adminConn = mysql.getConnection(Database.ADMIN);

            LogIn logInScreen = new LogIn();
            logInScreen.setVisible(true);      

            //Sales report = new Sales();
            //report.main(args);
        }catch (InstantiationException e) {
            e.printStackTrace();
        }catch (IllegalAccessException e) {
            e.printStackTrace();
        }catch(SQLException e){
            e.printStackTrace();
        }catch(ClassNotFoundException e){
            e.printStackTrace();
        }
    }

    /**
     * Utility method to print the string in the same line
     * @param s 
     */
    private static void print(String s){
        System.out.print(s);
    }
    /**
     * Utility method to print the string in a new line
     * @param s 
     */
    private static void println(String s){
        System.out.println(s);
    }
}
